﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace IcarusProject.Tiles
{
    public class Tileset
    {
        #region Attributs
        //Ensemble de tuiles
        private Dictionary<int, Tile> _tileSet;

        private Tile _floor;
        private Tile _verticalWall;
        private Tile _horizontalWall;
        private Tile _corner;

        //Singleton
        private static Tileset _singleton;
        #endregion

        #region Constructeur
        private Tileset()
        {
            _tileSet = new Dictionary<int, Tile>();

            _floor = new Tile(0).SetWalkable();
            _verticalWall = new Tile(1).SetColorEffect(Color.Black);
            _horizontalWall = new Tile(2).SetColorEffect(Color.Black);
            _corner = new Tile(3).SetColorEffect(Color.Black);

            _tileSet.Add(_floor.ID, _floor);
            _tileSet.Add(_verticalWall.ID, _verticalWall);
            _tileSet.Add(_horizontalWall.ID, _horizontalWall);
            _tileSet.Add(_corner.ID, _corner);
        }
        #endregion

        #region Proprietes
        #endregion

        #region Methodes
        public static Tileset GetSingleton()
        {
            if (_singleton == null)
                _singleton = new Tileset();
            return _singleton;
        }

        public Tile this[int id]
        {
            get
            {
                Tile r = null;
                if (_tileSet.ContainsKey(id))
                    r = _tileSet[id];
                return r;
            }
        }
        #endregion

        #region TileID
        public int FloorID
        {
            get { return _floor.ID; }
        }

        public int VWallId
        {
            get { return _verticalWall.ID; }
        }

        public int HWallId
        {
            get { return _horizontalWall.ID; }
        }

        public int CornerId
        {
            get { return _corner.ID; }
        }
        #endregion
    }
}
